package com.ihr360.insurance.config;

import com.ihr360.insurance.model.dto.benefits.CompanyBenefit;
import com.ihr360.insurance.model.dto.benefits.CompanyBenefitConfig;
import com.ihr360.insurance.model.dto.benefits.MandatoryBenefitGroup;
import com.ihr360.insurance.model.dto.benefits.MandatoryBenefitTemplate;
import com.ihr360.insurance.model.dto.benefits.MandatoryBenefitsMode;
import com.ihr360.insurance.model.dto.benefits.MandatoryBenefitsType;
import com.ihr360.insurance.model.dto.benefits.PaymentConfig;
import com.ihr360.insurance.model.dto.ledger.MonthlyLedger;
import com.ihr360.insurance.model.dto.ledger.MonthlyLedgerSummary;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter;
import org.springframework.http.MediaType;

@Configuration
public class DataRestConfig {

    /**
     * 针对Spring Data Rest的配置
     * @return
     */
    @Bean
    public RepositoryRestConfigurer repositoryRestConfigurer() {
        return new RepositoryRestConfigurerAdapter() {
            @Override
            public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
                config.exposeIdsFor(MandatoryBenefitsType.class);
                config.exposeIdsFor(MandatoryBenefitGroup.class);
                config.exposeIdsFor(MandatoryBenefitsMode.class);
                config.exposeIdsFor(MandatoryBenefitTemplate.class);
                config.exposeIdsFor(PaymentConfig.class);
                config.exposeIdsFor(CompanyBenefitConfig.class);
                config.exposeIdsFor(CompanyBenefit.class);
                config.exposeIdsFor(MonthlyLedger.class);
                config.exposeIdsFor(MonthlyLedgerSummary.class);
                config.setDefaultMediaType(MediaType.APPLICATION_JSON_UTF8);
            }
        };
    }


}